home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / compat / matherr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  2.0 KB  |  69 lines  |  [TEXT/ttxt]

  1. /* 
  2.  * tclMatherr.c --
  3.  *
  4.  *    This function provides a default implementation of the
  5.  *    "matherr" function, for SYS-V systems where it's needed.
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * All rights reserved.
  9.  *
  10.  * Permission is hereby granted, without written agreement and without
  11.  * license or royalty fees, to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose, provided that the
  13.  * above copyright notice and the following two paragraphs appear in
  14.  * all copies of this software.
  15.  * 
  16.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20.  *
  21.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26.  */
  27.  
  28. #include "std-c.h"
  29. #include <math.h>
  30. #include "std-os.h"
  31.  
  32. #ifdef NO_ERRNO_H
  33. extern int errno;
  34. #define EDOM 33
  35. #define ERANGE 34
  36. #endif
  37.  
  38.  
  39. /*
  40.  *----------------------------------------------------------------------
  41.  *
  42.  * matherr --
  43.  *
  44.  *    This procedure is invoked on Sys-V systems when certain
  45.  *    errors occur in mathematical functions.  Type "man matherr"
  46.  *    for more information on how this function works.
  47.  *
  48.  * Results:
  49.  *    Returns 1 to indicate that we've handled the error
  50.  *    locally.
  51.  *
  52.  * Side effects:
  53.  *    Sets errno based on what's in xPtr.
  54.  *
  55.  *----------------------------------------------------------------------
  56.  */
  57.  
  58. int
  59. matherr(xPtr)
  60.     struct exception *xPtr;    /* Describes error that occurred. */
  61. {
  62.     if ((xPtr->type == DOMAIN) || (xPtr->type == SING)) {
  63.     errno = EDOM;
  64.     } else {
  65.     errno = ERANGE;
  66.     }
  67.     return 1;
  68. }
  69.